Hi Team, I am working on a dxl, and struggling to reset access of attribute definition & value access from parent. the use case is - If user select any Folder and run dxl script by script should reset attribute access (definition & value) in all modules within folder and it's subfloder to inherit from parent. Could you help help me out on this? or any generic script is available then please let me know. Thanks, Regards, Rahij Rahij - Fri Jan 19 00:50:49 EST 2018 |
Re: Reset Module attribute, definition & type inherit from parent Well, have you checked the DXL Reference for access inheritance, specifically the functions inheritedDef, inheritedVal? |
Re: Reset Module attribute, definition & type inherit from parent PekkaMakinen - Fri Jan 19 01:07:07 EST 2018 Well, have you checked the DXL Reference for access inheritance, specifically the functions inheritedDef, inheritedVal? Hi Pekka, I have tried to use this function to my code but I am unable to get exacted result, could you please help me out on the same ? Below I have mentioned my sample code, please refer the same.
void processFormal(string mName)
{
moduleCount++
AttrDef ad
mReqs = edit(mName, false)
for at in mReqs do
{
unsetAll(mReqs, at)
}
for ad in mReqs do
{
inheritedDef(mReqs, ad)
inheritedVal(mReqs, ad)
}
file << "Module " mName " Processed\n"
save(mReqs)
close(mReqs)
}
|
Re: Reset Module attribute, definition & type inherit from parent Rahij - Wed Jan 31 08:43:55 EST 2018 Hi Pekka, I have tried to use this function to my code but I am unable to get exacted result, could you please help me out on the same ? Below I have mentioned my sample code, please refer the same.
void processFormal(string mName)
{
moduleCount++
AttrDef ad
mReqs = edit(mName, false)
for at in mReqs do
{
unsetAll(mReqs, at)
}
for ad in mReqs do
{
inheritedDef(mReqs, ad)
inheritedVal(mReqs, ad)
}
file << "Module " mName " Processed\n"
save(mReqs)
close(mReqs)
}
It seems that you are allowing DOORS to auto-declare your variables. That is not good, to turn that off see the Auto-Declare section in Language fundamentals (DXL Reference). Why I am saying that about auto-declare is that you are using an variable "at" for which type is not declared. As I fixed that to be AttrType, your script worked fine. |
Re: Reset Module attribute, definition & type inherit from parent PekkaMakinen - Thu Feb 01 00:32:37 EST 2018 It seems that you are allowing DOORS to auto-declare your variables. That is not good, to turn that off see the Auto-Declare section in Language fundamentals (DXL Reference). Why I am saying that about auto-declare is that you are using an variable "at" for which type is not declared. As I fixed that to be AttrType, your script worked fine. Hi Pekka, Thanks for your reply. I have updated my script(mentioned below), but still I am geeting error like - <Line :87>incorrect arguments for (=) <Line : 103> incorrectly concatenated tokens Could you please help me out to resolve the same ?
void processFormal(string mName)
{
Module modHandle = current
bool inheritedVal, inheritedDef
string valueRes, defRes, NameAD, mReqs
moduleCount++
mReqs = edit(mName, false)
void MakeInherited(Module in_mod, string in_NameAttr)
{
bool inheritedVal, inheritedDef
string ErrMess
AttrDef attrDef,ad
ad = find(in_mod, in_NameAttr)
if (null ad)
{ print "Cannot find attr *"
return()
}
ErrMess = isAccessInheritedVal(in_mod,ad,inheritedVal)
if (inheritedVal == false)
{
ErrMess = inheritedVal(in_mod, ad)
if (null ErrMess) //
then print in_NameAttr "\tSUCCESS! AccessVal is now INHERITED!\n"
else print in_NameAttr "\tFAILURE setting AccessVal: " ErrMess // ErrMess already has trailing '\n'
}
ErrMess = isAccessInheritedDef(in_mod,ad,inheritedDef)
if (inheritedDef == false)
{
ErrMess = inheritedDef(in_mod, attrDef)
if (null ErrMess ) //
then print in_NameAttr "\tSUCCESS! AccessDef is now INHERITED!\n"
else print in_NameAttr "\tFAILURE setting AccessDef: " ErrMess
}
}
/*for ad in mReqs do
{
inheritedDef(mReqs, ad)
inheritedVal(mReqs, ad)
}
file << "Module " mName " Processed\n"
save(mReqs)
close(mReqs) */
}
|
Re: Reset Module attribute, definition & type inherit from parent Rahij - Thu Feb 01 00:37:37 EST 2018 Hi Pekka, Thanks for your reply. I have updated my script(mentioned below), but still I am geeting error like - <Line :87>incorrect arguments for (=) <Line : 103> incorrectly concatenated tokens Could you please help me out to resolve the same ?
void processFormal(string mName)
{
Module modHandle = current
bool inheritedVal, inheritedDef
string valueRes, defRes, NameAD, mReqs
moduleCount++
mReqs = edit(mName, false)
void MakeInherited(Module in_mod, string in_NameAttr)
{
bool inheritedVal, inheritedDef
string ErrMess
AttrDef attrDef,ad
ad = find(in_mod, in_NameAttr)
if (null ad)
{ print "Cannot find attr *"
return()
}
ErrMess = isAccessInheritedVal(in_mod,ad,inheritedVal)
if (inheritedVal == false)
{
ErrMess = inheritedVal(in_mod, ad)
if (null ErrMess) //
then print in_NameAttr "\tSUCCESS! AccessVal is now INHERITED!\n"
else print in_NameAttr "\tFAILURE setting AccessVal: " ErrMess // ErrMess already has trailing '\n'
}
ErrMess = isAccessInheritedDef(in_mod,ad,inheritedDef)
if (inheritedDef == false)
{
ErrMess = inheritedDef(in_mod, attrDef)
if (null ErrMess ) //
then print in_NameAttr "\tSUCCESS! AccessDef is now INHERITED!\n"
else print in_NameAttr "\tFAILURE setting AccessDef: " ErrMess
}
}
/*for ad in mReqs do
{
inheritedDef(mReqs, ad)
inheritedVal(mReqs, ad)
}
file << "Module " mName " Processed\n"
save(mReqs)
close(mReqs) */
}
you do not have there so many lines ... but here is my toolbox script as an example. It is not goinf through all attributes, only named ones (the ATTRIBUTES array)
// Array of names - the attributes which should changed
const string ATTRIBUTES[] = {"Attribute1", "Attribute2"}
Folder f = current
Item CurrentFolder = item (fullName(f))
int NumAttributes = sizeof(ATTRIBUTES)
User currUser = find()
string currUserName = currUser.name
UserClass currUserClass = currUser.class
void processModule(string mName)
{
Module m = null
AttrDef ad = null
AttrType at = null
string AttrName = ""
int i = 0
bool OK = true
string err = ""
m = edit(mName, false)
if (null m)
{
print "Cannot open module " mName "\n"
return
}
current = m
for (i=0; i< NumAttributes; i++)
{
AttrName = ATTRIBUTES[i]
ad = find(m, AttrName)
if (!null ad)
{
if ((ad.object) && (canControlDef (ad)) && (canControlVal (ad)))
{
inheritedDef(m, ad)
inheritedVal(m, ad)
// Find the attribute type
at = ad.type
// Set inherit for type
if ((!null at) && (canControl(at)))
{
inherited(m, at)
}
else print "Error, " mName "- null attribute type or no canControl\n"
}
else
{
// Some problem, stop operation for this attribute
print "Error, no admin rights to module " mName " for attribute " AttrName "\n"
OK = false
continue
}
}
}
if (!OK)
{
print mName " - Error for definition - " AttrName "\n"
}
else
{
print mName " - OK - access right modified and saved\n"
save(m)
}
close(m, false)
}
void processFolder(Folder f)
{
Item i = (Item null)
for i in f do
{
if (isDeleted(i)) continue
if ((type(i) == "Folder") || (type(i) == "Project"))
{
processFolder(folder(fullName(i)))
}
else if (type(i) == "Formal")
{
processModule(fullName(i))
}
}
}
// MAIN
//---------------------------------------------------------------------------------------
if ((stringOf(currUserClass) != "Administrator") && (stringOf(currUserClass) != "Database Manager"))
{
ack "Only the DOORS Administrator or Database Managers can run this script - halting"
{
halt
}
}
processFolder(f)
|